import type { Options, Settings } from './types';

export function updateSettings(
  defaultSettings: Settings,
  newSettings: Partial<Options>,
): Settings {
  return {
    ...defaultSettings,
    options: { ...defaultSettings.options, ...newSettings },
    cmf_settings: { ...defaultSettings.cmf_settings, ...newSettings },
    cdn_settings: { ...defaultSettings.cdn_settings, ...newSettings },
  };
}

export const defaultSettings: Settings = {
  options: {
    site_name: '',
    site_icp: '',
    site_gwa: '',
    site_admin_email: '',
    site_analytics: '',
    site_seo_title: '',
    site_seo_keywords: '',
    site_seo_description: '',
  },
  cmf_settings: { open_registration: '0', banned_usernames: '' },
  cdn_settings: { cdn_static_root: '' },
};
